import {createRouter, createWebHashHistory} from 'vue-router';
import createtConstantRoutes from './constantRoutes.js';
import createtAsyncRoutes from './asyncRoutes.js';

export const Layout = () => import('@/layout/index.vue');
export const constantRoutes = createtConstantRoutes(Layout);
export const asyncRoutes = createtAsyncRoutes(Layout);


// 创建路由实例
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 })
});

// 重置路由
export function resetRouter() {
  router.replace({path: '/login'});
  location.reload();
}

export default router;